
import "babel-polyfill";
import '../public/media.match';
import 'antd/dist/antd.css';
import '../scss/main.scss';

import React from 'react';
import ReactDom from 'react-dom';
import { Router,hashHistory } from 'react-router';
import { Main,MainDemoLayout } from 'kpl';
import {message} from 'antd';
import Login from './login/login';
import A101 from './a1/a101';
import A102 from './a1/a102';
import A201 from './a2/a201';
import A202 from './a2/a202';
import A203 from './a2/a203';
import A301 from './a3/a301';
import A302 from './a3/a302';
import A303 from './a3/a303';
import NotSupported from './notSupportedExplorer/notSupport';
import util from 'util';
const config = {
    onEnter: function (nextState, replace, callback) {
        callback();
    }
};
message.config({
    top: 300,
    duration: 3,
});

const routes = [{
    path: 'main',
    component: MainDemoLayout,
    onEnter: config.onEnter,
    childRoutes: [    
        {
            name: "a101", path: "a101", component: A101, onEnter: config.onEnter
        },
        {
            name: "a102", path: "a102", component: A102, onEnter: config.onEnter
        },
        {
            name: "a201", path: "a201", component: A201, onEnter: config.onEnter
        },
        {
            name: "a202", path: "a202", component: A202, onEnter: config.onEnter
        },
        {
            name: "a203", path: "a203", component: A203, onEnter: config.onEnter
        },
        {
            name: "a301", path: "a301", component: A301, onEnter: config.onEnter
        },
        {
            name: "a302", path: "a302", component: A302, onEnter: config.onEnter
        },
        {
            name: "a303", path: "a303", component: A303, onEnter: config.onEnter
        }
    ]
}, {
    path: 'login',
    component: Login
}, {
    path: 'notSupported',
    component: NotSupported
}, {
    path: "/",
    indexRoute: {
        onEnter: (nextState, replace, next) => {
            if (util.getLocalObj("userInfo").userid) {
                console.log(util.getLocalObj("userInfo").userid);
                replace("main");
            } else {
                replace("login");
            }
            replace("login");
            next()
        }
    }
}];

ReactDom.render(<Router routes={routes} history={hashHistory}/>, document.getElementById("app"));


